home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / bin / ubuntu-bug < prev    next >
Encoding:
Text File  |  2009-09-25  |  2.0 KB  |  69 lines

  1. #!/bin/sh -e
  2.  
  3. # filter out -p and -P for backwards compatibility
  4. if [ "$1" = "-p" ] || [ "$1" = "-P" ]; then
  5.     shift
  6. fi
  7.  
  8. if [ "$#" != 1 ] || [ "$1" = "--help" ]; then
  9.     echo "Usage: $0 <pid>|<packagename>|<program path>|<.crash file>" >&2
  10.     exit 1
  11. fi
  12.  
  13. # determine apport UI options based on argument type
  14. if test "$1" -gt 0 2>/dev/null; then
  15.     # numeric, consider it a PID
  16.     args="-f -P $1"
  17. elif [ "${1%.crash}" != "$1" ] || [ "${1%.apport}" != "$1" ] ; then
  18.     # crash file
  19.     args="-c"
  20.     farg="$1"
  21. elif expr "$1" : ".*/.*" >/dev/null; then
  22.     # program path
  23.     output=$(dpkg-query --search "$1" || echo '')
  24.         if expr "$output" : ".*,.*" >/dev/null; then
  25.             echo "Path '$1' matches more than one package" >&2
  26.             exit 1
  27.         elif [ -z "$output" ]; then
  28.             echo "Path '$1' does not match any package" >&2
  29.         fi
  30.  
  31.         package=${output%%:*}
  32.     args="-f -p $package"
  33. else
  34.     # package name
  35.     args="-f -p $1"
  36. fi
  37.  
  38. # check for X
  39. if [ -z "$DISPLAY" ]; then
  40.     if [ -x /usr/bin/apport-cli ]; then
  41.         /usr/bin/apport-cli $args "$farg"
  42.     else
  43.         echo "\$DISPLAY is not set. You need apport-cli to make this program work." >&2
  44.         exit 1
  45.     fi
  46. # do we have a running Gnome/KDE session
  47. elif pgrep -u `id -u` -x gnome-session >/dev/null && \
  48.     [ -x /usr/share/apport/apport-gtk ]; then
  49.     /usr/share/apport/apport-gtk $args "$farg"
  50. elif pgrep -u `id -u` -x ksmserver >/dev/null && \
  51.     [ -x /usr/share/apport/apport-qt ]; then
  52.         /usr/share/apport/apport-qt $args "$farg"
  53. # fall back to calling whichever is available
  54. elif [ -x /usr/share/apport/apport-gtk ]; then
  55.     /usr/share/apport/apport-gtk $args "$farg"
  56. elif [ -x /usr/share/apport/apport-qt ]; then
  57.     /usr/share/apport/apport-qt $args "$farg"
  58. elif [ -x /usr/bin/apport-cli ]; then
  59.     if [ -z "$TERM" ]; then
  60.         x-terminal-emulator -e /usr/bin/apport-cli $args "$farg"
  61.     else
  62.         /usr/bin/apport-cli $args "$farg"
  63.     fi
  64. else
  65.     echo "Neither apport-gtk, apport-qt or apport-cli is installed. Install either to make this program work." >&2
  66.     exit 1
  67. fi
  68.  
  69.